{include file="public/_header" /}
<div class="x-body">
    <a class="layui-btn layui-btn-small" class="layui-btn layui-btn layui-btn-mini " style="float: right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i>
    </a>
    <form class="layui-form" method="post" enctype="multipart/form-data" action="/admin/rule/index">
        广告规则
        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>页面停留时长
            </label>
            <div class="layui-input-inline">
                <input type="text" name="stay_time" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="{$data.stay_time}">
            </div><div class="layui-input-inline" style="margin-top: 13px">S</div>
        </div>


        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>页面浏览长度
            </label>
            <div class="layui-input-inline">
                <input type="text" name="stay_length" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="{$data.stay_length}">
            </div><div class="layui-input-inline" style="margin-top: 13px">%</div>
        </div>

        注意力规则
        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>页面停留时长
            </label>
            <div class="layui-input-inline">
                <input type="text" name="gaze_time" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="{$data.gaze_time}">
            </div><div class="layui-input-inline" style="margin-top: 13px">S</div>
        </div>

        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>页面浏览长度
            </label>
            <div class="layui-input-inline">
                <input type="text" name="gaze_length" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="{$data.gaze_length}">
            </div><div class="layui-input-inline" style="margin-top: 13px">%</div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>


    </form>
</div>

<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
                , layer = layui.layer;

        //自定义验证规则
        form.verify({
            nikename: function (value) {
                if (value.length < 5) {
                    return '昵称至少得5个字符啊';
                }
            }
            , pass: [/(.+){6,12}$/, '密码必须6到12位']
            , repass: function (value) {
                if ($('#L_pass').val() != $('#L_repass').val()) {
                    return '两次密码不一致';
                }
            }
        });

        //监听提交
        form.on('submit(add)', function (data) {
            console.log(data);
            //发异步，把数据提交给php
            layer.alert("增加成功", {icon: 6}, function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
            });
            return false;
        });


    });

    layui.use('laydate', function () {
        $ = layui.jquery;
        var laydate = layui.laydate;
        //日期时间范围
        laydate.render({
            elem: '#test10'
            , type: 'datetime'
            , range: true
        });
    });



</script>